package com.hmdp.controller;


import com.hmdp.dto.Result;
import com.hmdp.service.IFollowService;
import com.hmdp.utils.UserHolder;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;


@RestController
@RequestMapping("/follow")
@Api(tags = "关注接口")
public class FollowController {

    @Resource
    private IFollowService iFollowService;
    //尝试关注用户修改数据库
    @ApiOperation("关注或取消关注")
    @PutMapping("/{id}/{isfollow}")
    public Result follow(@PathVariable("id")Long followUserId, @PathVariable("isfollow") boolean isFollow){
        return iFollowService.follow(followUserId, isFollow);
    }

    //前端查询是否关注
    @ApiOperation("查询是否关注")
    @GetMapping("/or/not/{id}")
    public Result followed(@PathVariable("id")Long followUserId){
        return iFollowService.followed(followUserId);
    }

    //查询其他用户的共同关注
    @ApiOperation("查询共同关注")
    @GetMapping("/common/{id}")
    public Result followCommons(@PathVariable("id") Long id){
        return iFollowService.followCommons(id);
    }
}
